using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Commerce.Common
{
	/// <summary>
	/// Strongly-typed collection for the Order class.
	/// </summary>
	[Serializable]
	public partial class OrderCollection : ActiveList<Order,OrderCollection> 
	{	   
		public OrderCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the CSK_Store_Order table.
	/// </summary>
	[Serializable]
	public partial class Order : ActiveRecord<Order>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public Order()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public Order(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

        
		public Order(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public Order(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }

		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		public static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CSK_Store_Order", TableType.Table, DataService.GetInstance("dashCommerce"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarOrderID = new TableSchema.TableColumn(schema);
				colvarOrderID.ColumnName = "orderID";
				colvarOrderID.DataType = DbType.Int32;
				colvarOrderID.MaxLength = 0;
				colvarOrderID.AutoIncrement = true;
				colvarOrderID.IsNullable = false;
				colvarOrderID.IsPrimaryKey = true;
				colvarOrderID.IsForeignKey = false;
				colvarOrderID.IsReadOnly = false;
				colvarOrderID.DefaultSetting = @"";
				colvarOrderID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderID);
				
				TableSchema.TableColumn colvarOrderGUID = new TableSchema.TableColumn(schema);
				colvarOrderGUID.ColumnName = "orderGUID";
				colvarOrderGUID.DataType = DbType.String;
				colvarOrderGUID.MaxLength = 50;
				colvarOrderGUID.AutoIncrement = false;
				colvarOrderGUID.IsNullable = false;
				colvarOrderGUID.IsPrimaryKey = false;
				colvarOrderGUID.IsForeignKey = false;
				colvarOrderGUID.IsReadOnly = false;
				
						colvarOrderGUID.DefaultSetting = @"(newid())";
				colvarOrderGUID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderGUID);
				
				TableSchema.TableColumn colvarOrderNumber = new TableSchema.TableColumn(schema);
				colvarOrderNumber.ColumnName = "orderNumber";
				colvarOrderNumber.DataType = DbType.String;
				colvarOrderNumber.MaxLength = 50;
				colvarOrderNumber.AutoIncrement = false;
				colvarOrderNumber.IsNullable = true;
				colvarOrderNumber.IsPrimaryKey = false;
				colvarOrderNumber.IsForeignKey = false;
				colvarOrderNumber.IsReadOnly = false;
				colvarOrderNumber.DefaultSetting = @"";
				colvarOrderNumber.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderNumber);
				
				TableSchema.TableColumn colvarOrderDate = new TableSchema.TableColumn(schema);
				colvarOrderDate.ColumnName = "orderDate";
				colvarOrderDate.DataType = DbType.DateTime;
				colvarOrderDate.MaxLength = 0;
				colvarOrderDate.AutoIncrement = false;
				colvarOrderDate.IsNullable = false;
				colvarOrderDate.IsPrimaryKey = false;
				colvarOrderDate.IsForeignKey = false;
				colvarOrderDate.IsReadOnly = false;
				
						colvarOrderDate.DefaultSetting = @"(getdate())";
				colvarOrderDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderDate);
				
				TableSchema.TableColumn colvarOrderStatusID = new TableSchema.TableColumn(schema);
				colvarOrderStatusID.ColumnName = "orderStatusID";
				colvarOrderStatusID.DataType = DbType.Int32;
				colvarOrderStatusID.MaxLength = 0;
				colvarOrderStatusID.AutoIncrement = false;
				colvarOrderStatusID.IsNullable = false;
				colvarOrderStatusID.IsPrimaryKey = false;
				colvarOrderStatusID.IsForeignKey = false;
				colvarOrderStatusID.IsReadOnly = false;
				
						colvarOrderStatusID.DefaultSetting = @"((0))";
				colvarOrderStatusID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderStatusID);
				
				TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
				colvarUserName.ColumnName = "userName";
				colvarUserName.DataType = DbType.String;
				colvarUserName.MaxLength = 100;
				colvarUserName.AutoIncrement = false;
				colvarUserName.IsNullable = false;
				colvarUserName.IsPrimaryKey = false;
				colvarUserName.IsForeignKey = false;
				colvarUserName.IsReadOnly = false;
				colvarUserName.DefaultSetting = @"";
				colvarUserName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserName);
				
				TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
				colvarEmail.ColumnName = "email";
				colvarEmail.DataType = DbType.String;
				colvarEmail.MaxLength = 50;
				colvarEmail.AutoIncrement = false;
				colvarEmail.IsNullable = true;
				colvarEmail.IsPrimaryKey = false;
				colvarEmail.IsForeignKey = false;
				colvarEmail.IsReadOnly = false;
				colvarEmail.DefaultSetting = @"";
				colvarEmail.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEmail);
				
				TableSchema.TableColumn colvarFirstName = new TableSchema.TableColumn(schema);
				colvarFirstName.ColumnName = "firstName";
				colvarFirstName.DataType = DbType.String;
				colvarFirstName.MaxLength = 50;
				colvarFirstName.AutoIncrement = false;
				colvarFirstName.IsNullable = true;
				colvarFirstName.IsPrimaryKey = false;
				colvarFirstName.IsForeignKey = false;
				colvarFirstName.IsReadOnly = false;
				colvarFirstName.DefaultSetting = @"";
				colvarFirstName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFirstName);
				
				TableSchema.TableColumn colvarLastName = new TableSchema.TableColumn(schema);
				colvarLastName.ColumnName = "lastName";
				colvarLastName.DataType = DbType.String;
				colvarLastName.MaxLength = 50;
				colvarLastName.AutoIncrement = false;
				colvarLastName.IsNullable = true;
				colvarLastName.IsPrimaryKey = false;
				colvarLastName.IsForeignKey = false;
				colvarLastName.IsReadOnly = false;
				colvarLastName.DefaultSetting = @"";
				colvarLastName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLastName);
				
				TableSchema.TableColumn colvarShipPhone = new TableSchema.TableColumn(schema);
				colvarShipPhone.ColumnName = "shipPhone";
				colvarShipPhone.DataType = DbType.String;
				colvarShipPhone.MaxLength = 50;
				colvarShipPhone.AutoIncrement = false;
				colvarShipPhone.IsNullable = true;
				colvarShipPhone.IsPrimaryKey = false;
				colvarShipPhone.IsForeignKey = false;
				colvarShipPhone.IsReadOnly = false;
				colvarShipPhone.DefaultSetting = @"";
				colvarShipPhone.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShipPhone);
				
				TableSchema.TableColumn colvarShippingMethod = new TableSchema.TableColumn(schema);
				colvarShippingMethod.ColumnName = "shippingMethod";
				colvarShippingMethod.DataType = DbType.String;
				colvarShippingMethod.MaxLength = 100;
				colvarShippingMethod.AutoIncrement = false;
				colvarShippingMethod.IsNullable = true;
				colvarShippingMethod.IsPrimaryKey = false;
				colvarShippingMethod.IsForeignKey = false;
				colvarShippingMethod.IsReadOnly = false;
				colvarShippingMethod.DefaultSetting = @"";
				colvarShippingMethod.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShippingMethod);
				
				TableSchema.TableColumn colvarSubTotalAmount = new TableSchema.TableColumn(schema);
				colvarSubTotalAmount.ColumnName = "subTotalAmount";
				colvarSubTotalAmount.DataType = DbType.Currency;
				colvarSubTotalAmount.MaxLength = 0;
				colvarSubTotalAmount.AutoIncrement = false;
				colvarSubTotalAmount.IsNullable = false;
				colvarSubTotalAmount.IsPrimaryKey = false;
				colvarSubTotalAmount.IsForeignKey = false;
				colvarSubTotalAmount.IsReadOnly = false;
				
						colvarSubTotalAmount.DefaultSetting = @"((0))";
				colvarSubTotalAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubTotalAmount);
				
				TableSchema.TableColumn colvarShippingAmount = new TableSchema.TableColumn(schema);
				colvarShippingAmount.ColumnName = "shippingAmount";
				colvarShippingAmount.DataType = DbType.Currency;
				colvarShippingAmount.MaxLength = 0;
				colvarShippingAmount.AutoIncrement = false;
				colvarShippingAmount.IsNullable = false;
				colvarShippingAmount.IsPrimaryKey = false;
				colvarShippingAmount.IsForeignKey = false;
				colvarShippingAmount.IsReadOnly = false;
				
						colvarShippingAmount.DefaultSetting = @"((0))";
				colvarShippingAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShippingAmount);
				
				TableSchema.TableColumn colvarHandlingAmount = new TableSchema.TableColumn(schema);
				colvarHandlingAmount.ColumnName = "handlingAmount";
				colvarHandlingAmount.DataType = DbType.Currency;
				colvarHandlingAmount.MaxLength = 0;
				colvarHandlingAmount.AutoIncrement = false;
				colvarHandlingAmount.IsNullable = false;
				colvarHandlingAmount.IsPrimaryKey = false;
				colvarHandlingAmount.IsForeignKey = false;
				colvarHandlingAmount.IsReadOnly = false;
				
						colvarHandlingAmount.DefaultSetting = @"((0))";
				colvarHandlingAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarHandlingAmount);
				
				TableSchema.TableColumn colvarTaxAmount = new TableSchema.TableColumn(schema);
				colvarTaxAmount.ColumnName = "taxAmount";
				colvarTaxAmount.DataType = DbType.Currency;
				colvarTaxAmount.MaxLength = 0;
				colvarTaxAmount.AutoIncrement = false;
				colvarTaxAmount.IsNullable = false;
				colvarTaxAmount.IsPrimaryKey = false;
				colvarTaxAmount.IsForeignKey = false;
				colvarTaxAmount.IsReadOnly = false;
				
						colvarTaxAmount.DefaultSetting = @"((0))";
				colvarTaxAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTaxAmount);
				
				TableSchema.TableColumn colvarTaxRate = new TableSchema.TableColumn(schema);
				colvarTaxRate.ColumnName = "taxRate";
				colvarTaxRate.DataType = DbType.Decimal;
				colvarTaxRate.MaxLength = 0;
				colvarTaxRate.AutoIncrement = false;
				colvarTaxRate.IsNullable = false;
				colvarTaxRate.IsPrimaryKey = false;
				colvarTaxRate.IsForeignKey = false;
				colvarTaxRate.IsReadOnly = false;
				
						colvarTaxRate.DefaultSetting = @"((0))";
				colvarTaxRate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTaxRate);
				
				TableSchema.TableColumn colvarCouponCodes = new TableSchema.TableColumn(schema);
				colvarCouponCodes.ColumnName = "couponCodes";
				colvarCouponCodes.DataType = DbType.String;
				colvarCouponCodes.MaxLength = 50;
				colvarCouponCodes.AutoIncrement = false;
				colvarCouponCodes.IsNullable = true;
				colvarCouponCodes.IsPrimaryKey = false;
				colvarCouponCodes.IsForeignKey = false;
				colvarCouponCodes.IsReadOnly = false;
				colvarCouponCodes.DefaultSetting = @"";
				colvarCouponCodes.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCouponCodes);
				
				TableSchema.TableColumn colvarDiscountAmount = new TableSchema.TableColumn(schema);
				colvarDiscountAmount.ColumnName = "discountAmount";
				colvarDiscountAmount.DataType = DbType.Currency;
				colvarDiscountAmount.MaxLength = 0;
				colvarDiscountAmount.AutoIncrement = false;
				colvarDiscountAmount.IsNullable = false;
				colvarDiscountAmount.IsPrimaryKey = false;
				colvarDiscountAmount.IsForeignKey = false;
				colvarDiscountAmount.IsReadOnly = false;
				
						colvarDiscountAmount.DefaultSetting = @"((0))";
				colvarDiscountAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDiscountAmount);
				
				TableSchema.TableColumn colvarSpecialInstructions = new TableSchema.TableColumn(schema);
				colvarSpecialInstructions.ColumnName = "specialInstructions";
				colvarSpecialInstructions.DataType = DbType.String;
				colvarSpecialInstructions.MaxLength = 1500;
				colvarSpecialInstructions.AutoIncrement = false;
				colvarSpecialInstructions.IsNullable = true;
				colvarSpecialInstructions.IsPrimaryKey = false;
				colvarSpecialInstructions.IsForeignKey = false;
				colvarSpecialInstructions.IsReadOnly = false;
				colvarSpecialInstructions.DefaultSetting = @"";
				colvarSpecialInstructions.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSpecialInstructions);
				
				TableSchema.TableColumn colvarShipToAddress = new TableSchema.TableColumn(schema);
				colvarShipToAddress.ColumnName = "shipToAddress";
				colvarShipToAddress.DataType = DbType.String;
				colvarShipToAddress.MaxLength = 500;
				colvarShipToAddress.AutoIncrement = false;
				colvarShipToAddress.IsNullable = true;
				colvarShipToAddress.IsPrimaryKey = false;
				colvarShipToAddress.IsForeignKey = false;
				colvarShipToAddress.IsReadOnly = false;
				colvarShipToAddress.DefaultSetting = @"";
				colvarShipToAddress.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShipToAddress);
				
				TableSchema.TableColumn colvarBillToAddress = new TableSchema.TableColumn(schema);
				colvarBillToAddress.ColumnName = "billToAddress";
				colvarBillToAddress.DataType = DbType.String;
				colvarBillToAddress.MaxLength = 500;
				colvarBillToAddress.AutoIncrement = false;
				colvarBillToAddress.IsNullable = true;
				colvarBillToAddress.IsPrimaryKey = false;
				colvarBillToAddress.IsForeignKey = false;
				colvarBillToAddress.IsReadOnly = false;
				colvarBillToAddress.DefaultSetting = @"";
				colvarBillToAddress.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBillToAddress);
				
				TableSchema.TableColumn colvarUserIP = new TableSchema.TableColumn(schema);
				colvarUserIP.ColumnName = "userIP";
				colvarUserIP.DataType = DbType.String;
				colvarUserIP.MaxLength = 50;
				colvarUserIP.AutoIncrement = false;
				colvarUserIP.IsNullable = false;
				colvarUserIP.IsPrimaryKey = false;
				colvarUserIP.IsForeignKey = false;
				colvarUserIP.IsReadOnly = false;
				colvarUserIP.DefaultSetting = @"";
				colvarUserIP.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserIP);
				
				TableSchema.TableColumn colvarShippingTrackingNumber = new TableSchema.TableColumn(schema);
				colvarShippingTrackingNumber.ColumnName = "shippingTrackingNumber";
				colvarShippingTrackingNumber.DataType = DbType.String;
				colvarShippingTrackingNumber.MaxLength = 150;
				colvarShippingTrackingNumber.AutoIncrement = false;
				colvarShippingTrackingNumber.IsNullable = true;
				colvarShippingTrackingNumber.IsPrimaryKey = false;
				colvarShippingTrackingNumber.IsForeignKey = false;
				colvarShippingTrackingNumber.IsReadOnly = false;
				colvarShippingTrackingNumber.DefaultSetting = @"";
				colvarShippingTrackingNumber.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShippingTrackingNumber);
				
				TableSchema.TableColumn colvarNumberOfPackages = new TableSchema.TableColumn(schema);
				colvarNumberOfPackages.ColumnName = "numberOfPackages";
				colvarNumberOfPackages.DataType = DbType.Int32;
				colvarNumberOfPackages.MaxLength = 0;
				colvarNumberOfPackages.AutoIncrement = false;
				colvarNumberOfPackages.IsNullable = true;
				colvarNumberOfPackages.IsPrimaryKey = false;
				colvarNumberOfPackages.IsForeignKey = false;
				colvarNumberOfPackages.IsReadOnly = false;
				colvarNumberOfPackages.DefaultSetting = @"";
				colvarNumberOfPackages.ForeignKeyTableName = "";
				schema.Columns.Add(colvarNumberOfPackages);
				
				TableSchema.TableColumn colvarPackagingNotes = new TableSchema.TableColumn(schema);
				colvarPackagingNotes.ColumnName = "packagingNotes";
				colvarPackagingNotes.DataType = DbType.String;
				colvarPackagingNotes.MaxLength = 500;
				colvarPackagingNotes.AutoIncrement = false;
				colvarPackagingNotes.IsNullable = true;
				colvarPackagingNotes.IsPrimaryKey = false;
				colvarPackagingNotes.IsForeignKey = false;
				colvarPackagingNotes.IsReadOnly = false;
				colvarPackagingNotes.DefaultSetting = @"";
				colvarPackagingNotes.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPackagingNotes);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "createdOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = true;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				
						colvarCreatedOn.DefaultSetting = @"(getdate())";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
				colvarCreatedBy.ColumnName = "createdBy";
				colvarCreatedBy.DataType = DbType.String;
				colvarCreatedBy.MaxLength = 50;
				colvarCreatedBy.AutoIncrement = false;
				colvarCreatedBy.IsNullable = true;
				colvarCreatedBy.IsPrimaryKey = false;
				colvarCreatedBy.IsForeignKey = false;
				colvarCreatedBy.IsReadOnly = false;
				colvarCreatedBy.DefaultSetting = @"";
				colvarCreatedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedBy);
				
				TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
				colvarModifiedOn.ColumnName = "modifiedOn";
				colvarModifiedOn.DataType = DbType.DateTime;
				colvarModifiedOn.MaxLength = 0;
				colvarModifiedOn.AutoIncrement = false;
				colvarModifiedOn.IsNullable = true;
				colvarModifiedOn.IsPrimaryKey = false;
				colvarModifiedOn.IsForeignKey = false;
				colvarModifiedOn.IsReadOnly = false;
				
						colvarModifiedOn.DefaultSetting = @"(getdate())";
				colvarModifiedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedOn);
				
				TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
				colvarModifiedBy.ColumnName = "modifiedBy";
				colvarModifiedBy.DataType = DbType.String;
				colvarModifiedBy.MaxLength = 50;
				colvarModifiedBy.AutoIncrement = false;
				colvarModifiedBy.IsNullable = true;
				colvarModifiedBy.IsPrimaryKey = false;
				colvarModifiedBy.IsForeignKey = false;
				colvarModifiedBy.IsReadOnly = false;
				colvarModifiedBy.DefaultSetting = @"";
				colvarModifiedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedBy);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["dashCommerce"].AddSchema("CSK_Store_Order",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("OrderID")]
		public int OrderID 
		{
			get { return GetColumnValue<int>(Columns.OrderID); }

			set { SetColumnValue(Columns.OrderID, value); }

		}

		  
		[XmlAttribute("OrderGUID")]
		public string OrderGUID 
		{
			get { return GetColumnValue<string>(Columns.OrderGUID); }

			set { SetColumnValue(Columns.OrderGUID, value); }

		}

		  
		[XmlAttribute("OrderNumber")]
		public string OrderNumber 
		{
			get { return GetColumnValue<string>(Columns.OrderNumber); }

			set { SetColumnValue(Columns.OrderNumber, value); }

		}

		  
		[XmlAttribute("OrderDate")]
		public DateTime OrderDate 
		{
			get { return GetColumnValue<DateTime>(Columns.OrderDate); }

			set { SetColumnValue(Columns.OrderDate, value); }

		}

		  
		[XmlAttribute("OrderStatusID")]
		public int OrderStatusID 
		{
			get { return GetColumnValue<int>(Columns.OrderStatusID); }

			set { SetColumnValue(Columns.OrderStatusID, value); }

		}

		  
		[XmlAttribute("UserName")]
		public string UserName 
		{
			get { return GetColumnValue<string>(Columns.UserName); }

			set { SetColumnValue(Columns.UserName, value); }

		}

		  
		[XmlAttribute("Email")]
		public string Email 
		{
			get { return GetColumnValue<string>(Columns.Email); }

			set { SetColumnValue(Columns.Email, value); }

		}

		  
		[XmlAttribute("FirstName")]
		public string FirstName 
		{
			get { return GetColumnValue<string>(Columns.FirstName); }

			set { SetColumnValue(Columns.FirstName, value); }

		}

		  
		[XmlAttribute("LastName")]
		public string LastName 
		{
			get { return GetColumnValue<string>(Columns.LastName); }

			set { SetColumnValue(Columns.LastName, value); }

		}

		  
		[XmlAttribute("ShipPhone")]
		public string ShipPhone 
		{
			get { return GetColumnValue<string>(Columns.ShipPhone); }

			set { SetColumnValue(Columns.ShipPhone, value); }

		}

		  
		[XmlAttribute("ShippingMethod")]
		public string ShippingMethod 
		{
			get { return GetColumnValue<string>(Columns.ShippingMethod); }

			set { SetColumnValue(Columns.ShippingMethod, value); }

		}

		  
		[XmlAttribute("SubTotalAmount")]
		public decimal SubTotalAmount 
		{
			get { return GetColumnValue<decimal>(Columns.SubTotalAmount); }

			set { SetColumnValue(Columns.SubTotalAmount, value); }

		}

		  
		[XmlAttribute("ShippingAmount")]
		public decimal ShippingAmount 
		{
			get { return GetColumnValue<decimal>(Columns.ShippingAmount); }

			set { SetColumnValue(Columns.ShippingAmount, value); }

		}

		  
		[XmlAttribute("HandlingAmount")]
		public decimal HandlingAmount 
		{
			get { return GetColumnValue<decimal>(Columns.HandlingAmount); }

			set { SetColumnValue(Columns.HandlingAmount, value); }

		}

		  
		[XmlAttribute("TaxAmount")]
		public decimal TaxAmount 
		{
			get { return GetColumnValue<decimal>(Columns.TaxAmount); }

			set { SetColumnValue(Columns.TaxAmount, value); }

		}

		  
		[XmlAttribute("TaxRate")]
		public decimal TaxRate 
		{
			get { return GetColumnValue<decimal>(Columns.TaxRate); }

			set { SetColumnValue(Columns.TaxRate, value); }

		}

		  
		[XmlAttribute("CouponCodes")]
		public string CouponCodes 
		{
			get { return GetColumnValue<string>(Columns.CouponCodes); }

			set { SetColumnValue(Columns.CouponCodes, value); }

		}

		  
		[XmlAttribute("DiscountAmount")]
		public decimal DiscountAmount 
		{
			get { return GetColumnValue<decimal>(Columns.DiscountAmount); }

			set { SetColumnValue(Columns.DiscountAmount, value); }

		}

		  
		[XmlAttribute("SpecialInstructions")]
		public string SpecialInstructions 
		{
			get { return GetColumnValue<string>(Columns.SpecialInstructions); }

			set { SetColumnValue(Columns.SpecialInstructions, value); }

		}

		  
		[XmlAttribute("ShipToAddress")]
		public string ShipToAddress 
		{
			get { return GetColumnValue<string>(Columns.ShipToAddress); }

			set { SetColumnValue(Columns.ShipToAddress, value); }

		}

		  
		[XmlAttribute("BillToAddress")]
		public string BillToAddress 
		{
			get { return GetColumnValue<string>(Columns.BillToAddress); }

			set { SetColumnValue(Columns.BillToAddress, value); }

		}

		  
		[XmlAttribute("UserIP")]
		public string UserIP 
		{
			get { return GetColumnValue<string>(Columns.UserIP); }

			set { SetColumnValue(Columns.UserIP, value); }

		}

		  
		[XmlAttribute("ShippingTrackingNumber")]
		public string ShippingTrackingNumber 
		{
			get { return GetColumnValue<string>(Columns.ShippingTrackingNumber); }

			set { SetColumnValue(Columns.ShippingTrackingNumber, value); }

		}

		
		
		//private int? propNumberOfPackages;
		[XmlAttribute("NumberOfPackages")]
		public int NumberOfPackages 
		{
			get
			{
			int? propNumberOfPackages = GetColumnValue<int?>(Columns.NumberOfPackages);
				if (!propNumberOfPackages.HasValue)
					return 0;
				return propNumberOfPackages.Value;
			}

		   set { SetColumnValue(Columns.NumberOfPackages, value); }

		}

		
		[XmlIgnore]
		public bool NumberOfPackagesHasValue
		{
			get { return GetColumnValue<int?>("numberOfPackages") != null; }

			set
			{
				int? propNumberOfPackages = GetColumnValue<int?>(Columns.NumberOfPackages);
				if (!value)
					SetColumnValue(Columns.NumberOfPackages, null);
				else if (value && !propNumberOfPackages.HasValue)
					SetColumnValue(Columns.NumberOfPackages, 0);
		   }

		}

		
		  
		[XmlAttribute("PackagingNotes")]
		public string PackagingNotes 
		{
			get { return GetColumnValue<string>(Columns.PackagingNotes); }

			set { SetColumnValue(Columns.PackagingNotes, value); }

		}

		
		
		//private DateTime? propCreatedOn;
		[XmlAttribute("CreatedOn")]
		public DateTime CreatedOn 
		{
			get
			{
			DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!propCreatedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propCreatedOn.Value;
			}

		   set { SetColumnValue(Columns.CreatedOn, value); }

		}

		
		[XmlIgnore]
		public bool CreatedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("createdOn") != null; }

			set
			{
				DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!value)
					SetColumnValue(Columns.CreatedOn, null);
				else if (value && !propCreatedOn.HasValue)
					SetColumnValue(Columns.CreatedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("CreatedBy")]
		public string CreatedBy 
		{
			get { return GetColumnValue<string>(Columns.CreatedBy); }

			set { SetColumnValue(Columns.CreatedBy, value); }

		}

		
		
		//private DateTime? propModifiedOn;
		[XmlAttribute("ModifiedOn")]
		public DateTime ModifiedOn 
		{
			get
			{
			DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!propModifiedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propModifiedOn.Value;
			}

		   set { SetColumnValue(Columns.ModifiedOn, value); }

		}

		
		[XmlIgnore]
		public bool ModifiedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("modifiedOn") != null; }

			set
			{
				DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!value)
					SetColumnValue(Columns.ModifiedOn, null);
				else if (value && !propModifiedOn.HasValue)
					SetColumnValue(Columns.ModifiedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("ModifiedBy")]
		public string ModifiedBy 
		{
			get { return GetColumnValue<string>(Columns.ModifiedBy); }

			set { SetColumnValue(Columns.ModifiedBy, value); }

		}

		
		#endregion
		
		
		#region PrimaryKey Methods
		
		public Commerce.Common.OrderItemCollection OrderItemRecords()
		{
			return new Commerce.Common.OrderItemCollection().Where(OrderItem.Columns.OrderID, OrderID).Load();
		}

		public Commerce.Common.OrderNoteCollection OrderNoteRecords()
		{
			return new Commerce.Common.OrderNoteCollection().Where(OrderNote.Columns.OrderID, OrderID).Load();
		}

		public Commerce.Common.TransactionCollection TransactionRecords()
		{
			return new Commerce.Common.TransactionCollection().Where(Transaction.Columns.OrderID, OrderID).Load();
		}

		#endregion
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varOrderGUID,string varOrderNumber,DateTime varOrderDate,int varOrderStatusID,string varUserName,string varEmail,string varFirstName,string varLastName,string varShipPhone,string varShippingMethod,decimal varSubTotalAmount,decimal varShippingAmount,decimal varHandlingAmount,decimal varTaxAmount,decimal varTaxRate,string varCouponCodes,decimal varDiscountAmount,string varSpecialInstructions,string varShipToAddress,string varBillToAddress,string varUserIP,string varShippingTrackingNumber,int varNumberOfPackages,string varPackagingNotes,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy)
		{
			Order item = new Order();
			
			item.OrderGUID = varOrderGUID;
			
			item.OrderNumber = varOrderNumber;
			
			item.OrderDate = varOrderDate;
			
			item.OrderStatusID = varOrderStatusID;
			
			item.UserName = varUserName;
			
			item.Email = varEmail;
			
			item.FirstName = varFirstName;
			
			item.LastName = varLastName;
			
			item.ShipPhone = varShipPhone;
			
			item.ShippingMethod = varShippingMethod;
			
			item.SubTotalAmount = varSubTotalAmount;
			
			item.ShippingAmount = varShippingAmount;
			
			item.HandlingAmount = varHandlingAmount;
			
			item.TaxAmount = varTaxAmount;
			
			item.TaxRate = varTaxRate;
			
			item.CouponCodes = varCouponCodes;
			
			item.DiscountAmount = varDiscountAmount;
			
			item.SpecialInstructions = varSpecialInstructions;
			
			item.ShipToAddress = varShipToAddress;
			
			item.BillToAddress = varBillToAddress;
			
			item.UserIP = varUserIP;
			
			item.ShippingTrackingNumber = varShippingTrackingNumber;
			
			item.NumberOfPackages = varNumberOfPackages;
			
			item.PackagingNotes = varPackagingNotes;
			
			item.CreatedOn = varCreatedOn;
			
			item.CreatedBy = varCreatedBy;
			
			item.ModifiedOn = varModifiedOn;
			
			item.ModifiedBy = varModifiedBy;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varOrderID,string varOrderGUID,string varOrderNumber,DateTime varOrderDate,int varOrderStatusID,string varUserName,string varEmail,string varFirstName,string varLastName,string varShipPhone,string varShippingMethod,decimal varSubTotalAmount,decimal varShippingAmount,decimal varHandlingAmount,decimal varTaxAmount,decimal varTaxRate,string varCouponCodes,decimal varDiscountAmount,string varSpecialInstructions,string varShipToAddress,string varBillToAddress,string varUserIP,string varShippingTrackingNumber,int varNumberOfPackages,string varPackagingNotes,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy)
		{
			Order item = new Order();
			
				item.OrderID = varOrderID;
			
				item.OrderGUID = varOrderGUID;
			
				item.OrderNumber = varOrderNumber;
			
				item.OrderDate = varOrderDate;
			
				item.OrderStatusID = varOrderStatusID;
			
				item.UserName = varUserName;
			
				item.Email = varEmail;
			
				item.FirstName = varFirstName;
			
				item.LastName = varLastName;
			
				item.ShipPhone = varShipPhone;
			
				item.ShippingMethod = varShippingMethod;
			
				item.SubTotalAmount = varSubTotalAmount;
			
				item.ShippingAmount = varShippingAmount;
			
				item.HandlingAmount = varHandlingAmount;
			
				item.TaxAmount = varTaxAmount;
			
				item.TaxRate = varTaxRate;
			
				item.CouponCodes = varCouponCodes;
			
				item.DiscountAmount = varDiscountAmount;
			
				item.SpecialInstructions = varSpecialInstructions;
			
				item.ShipToAddress = varShipToAddress;
			
				item.BillToAddress = varBillToAddress;
			
				item.UserIP = varUserIP;
			
				item.ShippingTrackingNumber = varShippingTrackingNumber;
			
				item.NumberOfPackages = varNumberOfPackages;
			
				item.PackagingNotes = varPackagingNotes;
			
				item.CreatedOn = varCreatedOn;
			
				item.CreatedBy = varCreatedBy;
			
				item.ModifiedOn = varModifiedOn;
			
				item.ModifiedBy = varModifiedBy;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn OrderIDColumn
        {
            get { return Schema.Columns[0]; }

        }

        
        
        
        public static TableSchema.TableColumn OrderGUIDColumn
        {
            get { return Schema.Columns[1]; }

        }

        
        
        
        public static TableSchema.TableColumn OrderNumberColumn
        {
            get { return Schema.Columns[2]; }

        }

        
        
        
        public static TableSchema.TableColumn OrderDateColumn
        {
            get { return Schema.Columns[3]; }

        }

        
        
        
        public static TableSchema.TableColumn OrderStatusIDColumn
        {
            get { return Schema.Columns[4]; }

        }

        
        
        
        public static TableSchema.TableColumn UserNameColumn
        {
            get { return Schema.Columns[5]; }

        }

        
        
        
        public static TableSchema.TableColumn EmailColumn
        {
            get { return Schema.Columns[6]; }

        }

        
        
        
        public static TableSchema.TableColumn FirstNameColumn
        {
            get { return Schema.Columns[7]; }

        }

        
        
        
        public static TableSchema.TableColumn LastNameColumn
        {
            get { return Schema.Columns[8]; }

        }

        
        
        
        public static TableSchema.TableColumn ShipPhoneColumn
        {
            get { return Schema.Columns[9]; }

        }

        
        
        
        public static TableSchema.TableColumn ShippingMethodColumn
        {
            get { return Schema.Columns[10]; }

        }

        
        
        
        public static TableSchema.TableColumn SubTotalAmountColumn
        {
            get { return Schema.Columns[11]; }

        }

        
        
        
        public static TableSchema.TableColumn ShippingAmountColumn
        {
            get { return Schema.Columns[12]; }

        }

        
        
        
        public static TableSchema.TableColumn HandlingAmountColumn
        {
            get { return Schema.Columns[13]; }

        }

        
        
        
        public static TableSchema.TableColumn TaxAmountColumn
        {
            get { return Schema.Columns[14]; }

        }

        
        
        
        public static TableSchema.TableColumn TaxRateColumn
        {
            get { return Schema.Columns[15]; }

        }

        
        
        
        public static TableSchema.TableColumn CouponCodesColumn
        {
            get { return Schema.Columns[16]; }

        }

        
        
        
        public static TableSchema.TableColumn DiscountAmountColumn
        {
            get { return Schema.Columns[17]; }

        }

        
        
        
        public static TableSchema.TableColumn SpecialInstructionsColumn
        {
            get { return Schema.Columns[18]; }

        }

        
        
        
        public static TableSchema.TableColumn ShipToAddressColumn
        {
            get { return Schema.Columns[19]; }

        }

        
        
        
        public static TableSchema.TableColumn BillToAddressColumn
        {
            get { return Schema.Columns[20]; }

        }

        
        
        
        public static TableSchema.TableColumn UserIPColumn
        {
            get { return Schema.Columns[21]; }

        }

        
        
        
        public static TableSchema.TableColumn ShippingTrackingNumberColumn
        {
            get { return Schema.Columns[22]; }

        }

        
        
        
        public static TableSchema.TableColumn NumberOfPackagesColumn
        {
            get { return Schema.Columns[23]; }

        }

        
        
        
        public static TableSchema.TableColumn PackagingNotesColumn
        {
            get { return Schema.Columns[24]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedOnColumn
        {
            get { return Schema.Columns[25]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedByColumn
        {
            get { return Schema.Columns[26]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedOnColumn
        {
            get { return Schema.Columns[27]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedByColumn
        {
            get { return Schema.Columns[28]; }

        }

        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string OrderID = @"orderID";
			 public static string OrderGUID = @"orderGUID";
			 public static string OrderNumber = @"orderNumber";
			 public static string OrderDate = @"orderDate";
			 public static string OrderStatusID = @"orderStatusID";
			 public static string UserName = @"userName";
			 public static string Email = @"email";
			 public static string FirstName = @"firstName";
			 public static string LastName = @"lastName";
			 public static string ShipPhone = @"shipPhone";
			 public static string ShippingMethod = @"shippingMethod";
			 public static string SubTotalAmount = @"subTotalAmount";
			 public static string ShippingAmount = @"shippingAmount";
			 public static string HandlingAmount = @"handlingAmount";
			 public static string TaxAmount = @"taxAmount";
			 public static string TaxRate = @"taxRate";
			 public static string CouponCodes = @"couponCodes";
			 public static string DiscountAmount = @"discountAmount";
			 public static string SpecialInstructions = @"specialInstructions";
			 public static string ShipToAddress = @"shipToAddress";
			 public static string BillToAddress = @"billToAddress";
			 public static string UserIP = @"userIP";
			 public static string ShippingTrackingNumber = @"shippingTrackingNumber";
			 public static string NumberOfPackages = @"numberOfPackages";
			 public static string PackagingNotes = @"packagingNotes";
			 public static string CreatedOn = @"createdOn";
			 public static string CreatedBy = @"createdBy";
			 public static string ModifiedOn = @"modifiedOn";
			 public static string ModifiedBy = @"modifiedBy";
						
		}

		#endregion
		
		
		
	}

}

